define(function(require, exports, module){
	var thinktankdetailsTemp = require("text!../template/thinktankdetails.html");
	
	module.exports = Nuui.View.extend({		
		template:thinktankdetailsTemp,		
		onRender:function(){
			var view = this;
			App.request(App.server.getServePath(App.path.smartGroupAction), {
				success:function(data){
					if(data.ec){
						alert(data.em);
					}else{
						//获取目标元素的code 和id
		 				var id=App.storage.get('smartGroupListId');		
		 				var code=App.storage.get('smartGroupMenuCode');	
		 				
						var lists = data.smartGroupList[code].list;	
						var summaryCharLen=200;
						for(var i=0;i<lists.length;i++){
							
							if( lists[i].id==id){
								res=lists[i];
								var profile=res.personalProfile.substr(0,+summaryCharLen)+'...';
								if(res.status==1){
									view.$("#status img").attr('src','images/img/ai_y.png');
									view.$("#status ").attr('data-status','1');
								}else{
									view.$("#status img").attr('src','images/img/aijia1.png');
									view.$("#status ").attr('data-status','0');
								}
								view.$("#tank_name").html(res.name);
								view.$("#lecture").html(res.lecture);
								view.$("#position").html(res.position);
								view.$("#personalProfile").html(profile);
								
								view.$('.toggle-btn').on('tap',function(){
									if($(this).hasClass('active')){
										view.$("#personalProfile").html(profile);
										$(this).text('展开').removeClass('active up');
										
									}else{
										view.$("#personalProfile").html(res.personalProfile);
										$(this).text('收起').addClass('active up');
									}
									
								})
								view.$("#avatar img").attr('src','images/img/'+res.avatar);
							}
						}
						
					

					  }
				  }
			 });
		},
		
		onShow:function(){
			 var view=this;
			 view.$('#status').on('tap',function(){
				 var status=$(this).attr('data-status');
				 if(status=="1"){
					 Nuui.utils.toast('取消关注成功',{"title":""});
					 $(this).find('img').attr('src','images/img/aijia1.png');
					 $(this).attr('data-status','0');
					 return false;
				 }else{
					 Nuui.utils.toast('关注成功',{"title":""});
					 $(this).find('img').attr('src','images/img/ai_y.png');
					 $(this).attr('data-status','1');
				 }
			 })
			//水波图
            $("#dowebok").waterbubble();
            $("#dowebok1").waterbubble();

		}
		
	});	
});